﻿using EntitiesLayer;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAccessLayer
{
    public class DataAccessAbstraction
    {
        private Bridge databaseManager;

        #region Singleton

        private static readonly object padlock = new object();

        private static volatile DataAccessAbstraction dataAccess;

        public static DataAccessAbstraction DataAccess
        {
            get
            {
                if (dataAccess == null)
                    lock (padlock)
                        if (dataAccess == null)
                            dataAccess = new DataAccessAbstraction();

                return dataAccess;
            }
        }

        #endregion

        private DataAccessAbstraction()
        {
            // Création d'un manager de connexion SQL
            databaseManager = new SqlManager();
        }

        #region List Properties

        public IList<Joueur> Players
        {
            get
            {
                return databaseManager.Players;
            }
        }

        public IList<Reservation> Reservations
        {
            get
            {
                return databaseManager.Reservations;
            }
        }

        public IList<Equipe> Teams
        {
            get
            {
                return databaseManager.Teams;
            }
        }

        public IList<Coupe> Cups
        {
            get
            {
                return databaseManager.Cups;
            }
        }

        public IList<Stade> Stadiums
        {
            get
            {
                return databaseManager.Stadiums;
            }
        }

        public IList<Match> Matches
        {
            get
            {
                return databaseManager.Matches;
            }
        }

        public IList<Spectateur> Spectateurs
        {
            get
            {
                return databaseManager.Spectateurs;
            }
        }

        #endregion
    }
}
